package com.behome.netty.netty_D.bean;

import com.behome.netty.common.ByteConventerKit;

import java.nio.ByteBuffer;

/**
 * Auxiliary 辅助数据
 *
 * @author bh_ljy
 * @version 2024/05/27 14:39
 **/
public class Auxiliary {
    //辅助数据类型默认61
    private byte dataType = 61;
    private byte[] dataLength;
    private byte[] data;

    public Auxiliary() {
    }

    public byte getDataType() {
        return this.dataType;
    }

    public void setDataType(byte dataType) {
        this.dataType = dataType;
    }

    public byte[] getData() {
        return this.data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }

    public byte[] serialize() {
        int length = 3 + this.data.length;
        ByteBuffer byteBuffer = ByteBuffer.allocate(length);
        byteBuffer.put(this.dataType)
                .put(ByteConventerKit.shortToBytes((new Integer(this.data.length)).shortValue()))
                .put(this.data);
        return byteBuffer.array();
    }
}
